﻿@model IEnumerable<PartyManagement.Models.Group>
@using PartyManagement.Models;
@{
    Group group = new Group();
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_MyLayout.cshtml";
    
}

<h2>Groups</h2>

<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.groupName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.UserProfile.UserName)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.groupName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UserProfile.UserName)
            </td>
            
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.groupID }) |
            @Html.ActionLink("Details", "Details", new { id = item.groupID }) | 
            @Html.ActionLink("Show Member", "ShowMember", new { id = item.groupID }) | 
            @Html.ActionLink("Add Member", "AddMember", new { id = item.groupID }) | 
            @Html.ActionLink("Delete", "Delete", new { id = item.groupID })
            </td>
        </tr>
    }

</table>
<p>
    <input value="Create Group" class="actCreate" type="button" />
</p>

<script>
    $(document).ready(function () {
        $(".create").hide()
        $(".actCreate").click(function () {
            $(".create").show();
            $(".editor-field").val("");

        });

        $("input[name='saveEvent']").submit(function () {
            $('table').load()
        });
        //-------------------------------------------------------------
        $(".addgroup").hide();

        $(".link_add_group").click(function () {
            $(".addgroup").show();
        });
    });

</script>

<div class="create">

    @using (Html.BeginForm("Create", "Group", FormMethod.Post))
    {
        @Html.ValidationSummary(true)
 
        <fieldset class="fieldsetEvent">
            <legend>Event</legend>

            <div class="editor-label">
                @Html.LabelFor(model => group.groupName)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => group.groupName)
            @Html.ValidationMessageFor(model => group.groupName)
            </div>



            <p>
                <input type="submit" value="Add" name="saveGroup" />
            </p>
        </fieldset>
   
    }

</div>
